package com.arvinclub.model.entity;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 评论实体类
 */
public class Comment
{
    /**
     * 用于数据库映射
     */
    private int id;
    private String content;//评论内容
    private Date date;//时间，面向数据库
    private User user;//此评论发布者
    private int status;//状态 1显示 0不显示
    private Blog blog;//对应博客


    /**
     * 用于前端显示
     */
    private String time;//时间，面向前端
    private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("YYYY年MM月dd日 HH:mm");

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public Date getDate()
    {
        return date;
    }

    public void setDate(Date date)
    {
        this.date = date;
        if (date != null)
            time = SIMPLE_DATE_FORMAT.format(date);
    }

    public User getUser()
    {
        return user;
    }

    public void setUser(User user)
    {
        this.user = user;
    }

    public String getTime()
    {
        return time;
    }

    public void setTime(String time)
    {
        this.time = time;
    }

    public int getStatus()
    {
        return status;
    }

    public void setStatus(int status)
    {
        this.status = status;
    }

    public Blog getBlog() {
        return blog;
    }

    public void setBlog(Blog blog) {
        this.blog = blog;
    }

    @Override
    public String toString()
    {
        return "Comment{" +
                "id=" + id +
                ", content='" + content + '\'' +
                ", user=" + user +
                ", time='" + time + '\'' +
                '}';
    }
}
